<template>
    <div class="panel minh_624">
        <div class="item_title pr">
            {{(isState == 1) ? '项目案例' : (isState == 2) ? '新增项目案例' : '编辑项目案例'}}
            <div class="tools-box" v-show="isState == 1">
                <a  class="displayB" style="cursor:pointer;" @click="addFun">
                    <i class="el-icon-edit-outline"></i>添加
                </a>
            </div>
        </div>
        <div class="padding_16">
            <!-- 项目案例 列表 -->
            <ItemCase v-if="isState == 1" @edit="editFun" />
            <!-- 新增、编辑  案例 -->
            <AddCase v-if="(isState == 2) || (isState == 3)" @list="listFun" :cpid="cpid" :type="isState" />
            
        </div>
    </div>
</template>
<script>

    import AddCase from '@/components/addcase'
    import ItemCase from '@/components/itemcase'
    export default {
        components: {AddCase,ItemCase},
        data(){
            return{
                infoData: {},
                sid: '',
                isState: 1,  //  1  详情     2  添加      3编辑
                cpid: '',  // 编辑时的id    
            }
        },
        methods: {
            init(){
                
                if(this.$route.query.edit){
                    this.addFun();
                }

            },
            //列表
            listFun(){
                this.isState = 1;
                this.cpid = '';
            },
            //添加  案例
            addFun(){
                this.isState = 2;
                this.cpid = '';
            },
            //编辑案例
            editFun(cpid){
                
                this.isState = 3;
                this.cpid = cpid;
            },
        },
        mounted(){
            this.init();
        }, 
    }
</script>
